﻿using System;
using Bingosoft.Modules.DataDictionary;
using Bingosoft.Web.Utils;
using System.Web.UI;

namespace Bingosoft.WebApp.Modules.DataDictionary
{
    public partial class DataDictionaryEdit : FormPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Save(object sender, EventArgs e)
        {
            string id = this.SmartFormView1["Id"] as string;
            string code = this.SmartFormView1["Code"] as string;
            
            if (this.DataDictionaryService.IsDictionaryCodeExist(code,id))
            {
                ScriptHelper.Alert(this,"编码必须保持唯一，请重新填写");
            }
            else
            {
                this.SmartFormView1.SaveOrUpdate();
                ScriptHelper.CloseDialog(this, "true");
            }
        }

        private DataDictionaryService _dataDictionaryService;
        private DataDictionaryService DataDictionaryService
        {
            get
            {
                return _dataDictionaryService ??
                       (_dataDictionaryService = ObjectHelper.GetObject<DataDictionaryService>());
            }
        }
    }
}